package cn.tedu.javagame.Plane;

import javax.swing.*;
import java.awt.*;

public class Heart extends FlyObject{
    int type; //0加生命 1加火力 2加金币
    int state;
//    static Image img;
//    static Image[] imgs;
    //静态代码块
    public Heart(){
        super();
        imgs = new Image[9];
        img = new ImageIcon("plane/qq00.png").getImage();
        for(int i=0;i<imgs.length;i++){
            imgs[i] = new ImageIcon("plane/qq0"+i+".png").getImage();
        }
        this.x = (int)(Math.random()*(ShootFrame.WIDTH-img.getWidth(null)));
        this.y = -img.getHeight(null);
        this.type = (int)(Math.random()*3);
        this.state = (int)(Math.random()*2);

    }
    public void move(){
        this.y+=speed;
        if(this.state == 1){
            this.x -= 5;
        }
        if(this.state == 0){
            this.x += 5;
        }
        //碰到边界
        if (this.x <= 0)this.state=0;
        if (this.x >= ShootFrame.WIDTH-this.img.getWidth(null))this.state=1;
    }
}
